import React from 'react';
import { Icon } from 'antd';
import {WeaLocaleProvider} from 'ecCom';
import './../../style/feedback/feedBack';
const getLabel = WeaLocaleProvider.getLabel;
export default class FeedBack extends React.Component {
  constructor(props) {
    super(props)
    this.state={
      
    }
  }
  render() {
    const { dataSource,hasMore,className,style} = this.props;
    return (
      <div className={"wea-workrelate-feedback " + (className ? className : "")} style={style}>
        {
          dataSource && dataSource.length > 0 ? dataSource.map((elemnet, index) => {
            return (
              <div className="feedback-comment">
              
                <div className="feedback-left"><a href='javaScript:void(0)' onClick={e => { openhrm(elemnet.hrmid); window.pointerXY(e) }} title={elemnet.hrmname} ><Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@uis0rz@${index}`} type="user" /></a></div>
                <div className="feedback-right">
                    <div className="feedback-right-name"><a href='javaScript:void(0)' onClick={e => { openhrm(elemnet.hrmid); window.pointerXY(e) }} title={elemnet.hrmname} >{elemnet.hrmname}</a><span className="feedback-last-time">{elemnet.operatedate}</span></div>
                    <div className="feedback-last">
                      {elemnet.isnew && <span title={getLabel(84048,"新反馈")} className="feedback-last-span-new">new</span>}
                    </div>
                    <div className="feedback-right-content wea-workrelate-remark-number" dangerouslySetInnerHTML={{ __html: elemnet.content }}></div>
                </div>
              </div>)
          }) : ''
        }
          {hasMore ? <div className="feedback-comment-more" onClick={()=>this.onMoreClick()}>加载更多 <Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@4vp7c5`} type="down" /></div> : 
          (dataSource && dataSource.length > 0 )?<div className="feedback-split"></div>:""}
      </div>
    )
  }
  onMoreClick(id,name,type){
    if(typeof this.props.onMoreClick === "function"){
      this.props.onMoreClick();
    }
  }
  removeHTMLTag(str) {
    str = str.replace(/&nbsp;/ig, "");
    str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
    str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
    str = str.replace(/ /ig, '');//去掉 
    return str;
  }
}

